package com.magesti.ressource;

import java.util.ArrayList;
import java.util.List;

public class MessagesAide {
	// Ce beans permet d'afficher les messages dans la section d'aide.

	private List<Section> sections;

	public MessagesAide() {
		sections = new ArrayList<Section>();
	}

	public List<Section> getSections() {
		return sections;
	}

	public void setSections(List<Section> sections) {
		this.sections = sections;
	}

	public void addSection(Section s) {
		this.sections.add(s);
	}

	public class Section {
		public Section() {
			listeQr = new ArrayList<QuestionReponse>();
		}

		public Section(String _titre) {
			listeQr = new ArrayList<QuestionReponse>();
			this.titre = _titre;
		}

		private String titre;
		private List<QuestionReponse> listeQr;

		public void addQuestionReponse(QuestionReponse qr) {
			listeQr.add(qr);
		}

		public List<QuestionReponse> getListeQr() {
			return listeQr;
		}

		public void setListeQr(List<QuestionReponse> listeQr) {
			this.listeQr = listeQr;
		}

		public String getTitre() {
			return titre;
		}

		public void setTitre(String titre) {
			this.titre = titre;
		}
	}

	public class QuestionReponse {
		private String Question;
		private String Reponse;

		public String getQuestion() {
			return Question;
		}

		public void setQuestion(String question) {
			Question = question;
		}

		public String getReponse() {
			return Reponse;
		}

		public void setReponse(String reponse) {
			Reponse = reponse;
		}

	}

	public String toString() {
		String out = "toString QuestionReponse:\n";
		if (!sections.isEmpty()) {
			for (Section s : sections) {
				out += "Nom section :" + s.getTitre() + "\n";
				List<QuestionReponse> lqr = s.listeQr;
				if (!lqr.isEmpty()) {
					for (QuestionReponse qr : lqr) {
						out += "\t Q:" + qr.Question + "\n";
						out += "\t R:" + qr.Reponse + "\n";
					}
				} else {
					out += "\t Aucune question/reponse pour cette section.\n";
				}
			}
		} else {
			out += "Aucune sections.\n";
		}
		return out;
	}
}
